#include <bits/stdc++.h>
#define LL long long
using namespace std;

int main() {
  freopen("cow.in", "r", stdin);
  freopen("cow.out", "w", stdout);
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  string s;
  LL cnt_C = 0, cnt_CO = 0, ans = 0;

  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'C') {
      cnt_C++;
    } else if (s[i] == 'O') {
      cnt_CO += cnt_C;
    } else if (s[i] == 'W') {
      ans += cnt_CO;
    }
  }
  cout << ans << '\n';
  return 0;
}